const ApiPrefix = './admin';
const Api = {
    registerUrl: ApiPrefix + '/register.php',
    getProductUrl: ApiPrefix + '/proList.php',
    loginUrl: ApiPrefix + '/login.php',
    detailsUrl: ApiPrefix + '/details.php',
    confirmOrder: ApiPrefix + '/confirm_order.php',
    shopCartUrl:ApiPrefix + '/shopCart.php',
};
footerHref();

//隔开
$("#search").focus(function(){
   window.open("pro_search.html","_self");
});

$("#back").tap(function(){
    console.log(1)
    window.history.go(-1);
});

function requestEvent(option) {
    var def = $.Deferred();
    var config = {
        type: 'get',
        dataType: 'json',
        success: function (res) {
            def.resolve(res); //resolve表示解决了
        },
        error: function (a, b, error) {
            def.reject(error); //reject表示拒绝，也就是所谓的“失败”
        }
    };
    $.extend(true, config, option) //jquery的一个拓展参数的方法
    $.ajax(config);
    return def.promise(); //promise表示承诺
}

function unSerializeArray(arr) {
    var obj = {};
    arr.forEach(function (item) {
        var key = item.name;
        obj[key] = item.value;
    });
    return obj;
}

function footerHref() {
    var footer = $("footer");
    footer.find(".option1").tap(function () {
        window.open("home.html", "_self");
    });
    footer.find(".option2").tap(function () {
        window.open("pro_categories.html", "_self");
    });
    footer.find(".option3").tap(function () {
        window.open("shop_cart.html", "_self");
    });
    footer.find(".option4").tap(function () {
        window.open("user.html", "_self");
    });
}